pipeline {
    agent any
    triggers {
        // curl -X POST 
        // -H "Content-Type: application/json" 
        // -H "headerWithNumber: nbr123" 
        // -H "headerWithString: a b c" 
        // -d ' { "before": "1848f12", "after": "5cab1", "ref": "refs/heads/develop" }' 
        // -vs http://jenkins.example.com:32203/generic-webhook-trigger/invoke?token=abc123&requestWithNumber=nbr20123&requestWithString=astring
        
        GenericTrigger(
            genericVariables: [
                [key: 'ref', value: '$.ref'],
                [key: 'before', value: '$.before']
            ],
            genericRequestVariables: [
                [key: 'requestWithNumber', regexpFilter: '[^0-9]'],
                [key: 'requestWithString', regexpFilter: '']
            ],
            genericHeaderVariables: [
                [key: 'headerWithNumber', regexpFilter: '[^0-9]'],
                [key: 'headerWithString', regexpFilter: '']
            ],

            causeString: 'Triggered on $ref',

            token: 'abc123',
            tokenCredentialId: '',

            printContributedVariables: true,
            printPostContent: true,

            silentResponse: false,

            regexpFilterText: '$ref',
            regexpFilterExpression: 'refs/heads/'
        )
    }
    stages {
        stage('Some step') {
            steps {
                sh """
                echo $ref
                echo $before
                echo $requestWithNumber
                echo $requestWithString
                echo $headerWithNumber
                echo $headerWithString
                """
            }
        }
    }
}